package com.xydpeng.tech.order.enums;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2024/12/11
 * @description: 订单状态枚举
 */
public enum OrderStatusEnum {

    PENDING(0, "待支付"),
    PAID(5, "待发货"),
    SHIPPED(10, "已发货"),
    COMPLETED(15, "已完成"),
    CANCELLED(20, "已取消");
    /**
     * 状态值
     */
    private final Integer code;
    /**
     * 状态名
     */
    private final String name;

    OrderStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    public static OrderStatusEnum getByCode(Integer status) {
        for (OrderStatusEnum statusEnum : OrderStatusEnum.values()) {
            if (statusEnum.getCode().equals(status)) {
                return statusEnum;
            }
        }
        return null;
    }
}
